package com.project_doctor.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.project_doctor.pojo.Doctor;
import com.project_doctor.pojo.Dto.DoctorRequest;
import com.project_doctor.service.DoctorService;
import com.project_doctor.mapper.DoctorMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.Collections;
import java.util.Date;
import java.util.List;

/**
* @author 龙龙与贝儿
* @description 针对表【t_doctor】的数据库操作Service实现
* @createDate 2025-06-03 11:07:18
*/
@Service
public class DoctorServiceImpl extends ServiceImpl<DoctorMapper, Doctor>
    implements DoctorService{

    @Autowired
    DoctorMapper doctorMapper;
    @Override
    public List<Doctor> getAllDoctors(DoctorRequest doctorRequest) {
        List<Doctor> doctors = doctorMapper.getAllDoctorsWithRoleAndTeam(doctorRequest);
        return doctors;
    }

    @Override
    public List<Doctor> getDoctorByBatchId(List<Long> ids) {
        List<Doctor> doctors = doctorMapper.getDoctorByBatchId(ids);
        return doctors;
    }

    @Override
    public Doctor getUserById(Long userId) {
        return baseMapper.selectById(userId);
    }

    @Override
    public String getUserName(Long userId) {
        Doctor user = baseMapper.selectById(userId);
        return user != null ? user.getName() : "";
    }

    @Override
    public String getUserAvatar(Long userId) {
        Doctor user = baseMapper.selectById(userId);
        return user != null ? user.getAvatar() : "";
    }

    @Override
    public void updateUserStatus(Long userId, String status) {
        Doctor user = new Doctor();
        user.setId(userId);
        user.setStatus(status);
        user.setUpdateTime(new Date());

        baseMapper.updateById(user);
    }
}




